package com.myway.components.payment.yeepay.distribute;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.myway.components.payment.yeepay.interFace.YeepayInterFace;
// 分账
public class Distribute {	
	// 生成支付订单的重定向的url
	public static String getDistributePayUrl(HttpServletRequest request,String merId){
		Map fixParameter = Info.getDistributePayFixParameter(merId);
		//String url = Info.getDistributePayUrl();
		String[] hmacOrder = Info.getDistributePayHmacOrder();
		//String keyValue = Info.getKeyValue();
		return YeepayInterFace.getRequestUrl(request, fixParameter, "url", hmacOrder, "keyvalue");
	}
	
	// 生成支付订单的提交的form表单，submitValue为提交的form表单时的
	public static String getDistributePayForm(HttpServletRequest request, String formName, String submitValue,String merId){
		Map fixParameter = Info.getDistributePayFixParameter(merId);
		String[] hmacOrder = Info.getDistributePayHmacOrder();
		//String keyValue = Info.getKeyValue();
		//String url = Info.getDistributePayUrl();
		return YeepayInterFace.getRequestForm(request, formName, submitValue, fixParameter, hmacOrder, "keyValue", "url");
	}
	// 获得支付返回callback的参数
	public static Map distributePayCallback(HttpServletRequest request){
		String[] callbackHmacOrder = Info.getDistributePayCallbackHmacOrder();
		//String keyValue = Info.getKeyValue();
		return YeepayInterFace.getCallbackMap(request, callbackHmacOrder, "keyvalue" );
	}
	// 退款
	public static Map getDistributeRefundExtBackMap(HttpServletRequest request,String merId){
		Map fixParameter = Info.getDistributeRefundExtFixParameter(merId);
		String[] hmacOrder = Info.getDistributeRefundExtHmacOrder();
		String[] backHmacOrder = Info.getDistributeRefundExtBackHmacOrder();
		//String url = Info.getDistributeRefundExtUrl();
		//String keyValue = Info.getKeyValue();
		return YeepayInterFace.getRequestBackMap(request, fixParameter, hmacOrder, backHmacOrder, "url", "keyvalue" );
	}
	// 子商户注册
	public static String getDistributeIndirectRegisterForm(HttpServletRequest request, String formName, String submitValue,String merId){
		Map fixParameter = Info.getDistributeRegistMerchantFixParameter(merId);
		String[] hmacOrder = Info.getDistributeRegistMerchantHmacOrder();
		//String keyValue = Info.getKeyValue();
		//String url = Info.getDistributeRegistMerchantUrl();
		return YeepayInterFace.getRequestForm(request, formName, submitValue, fixParameter, hmacOrder, "keyValue", "url");
	}	
	// 解冻分账
	public static Map getDistributePaymentConfirmBackMap(HttpServletRequest request,String merId){
		Map fixParameter = Info.getDistributePaymentConfirmFixParameter(merId);
		String[] hmacOrder = Info.getDistributePaymentConfirmHmacOrder();
		String[] backHmacOrder = Info.getDistributePaymentConfirmBackHmacOrder();
		//String url = Info.getDistributePaymentConfirmUrl();
		//String keyValue = Info.getKeyValue();
		return YeepayInterFace.getRequestBackMap(request, fixParameter, hmacOrder, backHmacOrder, "url", "keyValue" );
	}
}
